<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Slideshow extends Public_Controller 
{

	function __construct()
	{
		parent::__construct();	
	}
	
	function index()
	{
            $data = array();
            $result = array();
            $gallery_id = 3;
            $Gallery = $this->load->model('galleries_model');
            $Gallery->get_by_id($gallery_id);
            if ( ! $Gallery->exists())
            {
                return show_404();
            }
            $data = $Gallery->images->order_by('sort', 'ASC')->get_by_gallery_id($gallery_id);
            foreach($data->all as $imageObj) {
                $result[] = array(  'image' => site_url().$imageObj->stored->filename,
                                    'url' => site_url().$imageObj->stored->filename,
                                    'title' => $imageObj->stored->title,
                            );
            }
            echo json_encode($result);
        }
}